package com.elong.businesstravel.base.utils;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.content.Context;

import com.android.support.jhf.utils.ConfigManager;
import com.android.support.jhf.utils.FileUtils;
import com.android.support.jhf.utils.SerializableObject;
import com.elong.businesstravel.entitys.City;
import com.elong.businesstravel.entitys.Poi;
import com.elong.businesstravel.entitys.TrainStation;

/**
 * 保存用户操作
 * 
 * @author lenovo
 * 
 */
public class SaveUserOperate {

	/** 入住离店时间 */
	public static final String IN_OUT_HOTEL_DATE = "in_out_hotel_date";
	/** 火车出发时间时间 */
	public static final String TRAIN_STARTING_DATE = "train_starting_date";
	/**价格星级*/
	public static final String PRICE_LEVEL = "price_level";
	/**城市*/
	public static final String HOTEL_CITY = "hotel_city";
	/**起始火车站*/
	public static final String START_TRAIN_STATION = "start_train_station";
	/**终点火车站*/
	public static final String END_TRAIN_STATION = "end_train_station";
	/**位置*/
	public static final String HOTEL_LOCATION = "hotel_location";
	/**保存用户姓名*/
	public static final String LIVE_NAME = "live_name";
	/**保存用户电话号码*/
	public static final String LIVE_PHONE = "live_phone";
	/**发票抬头*/
	public static final String INVOICE_TITLE = "invoice_title";
	/**收件人*/
	public static final String RECIPIENTS = "recipients";
	/**收件人电话号*/
	public static final String RECIPIENTS_PHONE = "recipients_phone";
	/**邮寄地址*/
	public static final String MAIL_ADDRESS = "mail_address";
	/**登陆电话号码*/
	public static final String LOGIN_PHONE = "login_phone";
	/**联合登陆昵称*/
	public static final String LOGIN_NICKNAME = "login_nickname";
	/**信用卡持卡人*/
	public static final String CARDHOLDER = "cardholder";
	/**身份证*/
	public static final String ID_CARD = "id_card";
	/**信用卡号*/
	public static final String CREDIT_CARD_NUMBER = "credit_card_number";
	/**cvv2，信用卡后面卡号末三位*/
	public static final String CVV2 = "cvv2";
	/**保存上一次的版本，用来比较是否弹出引导页*/
	public static final String LAST_VERSION_CODE = "last_version_code";
	/**验证邮箱*/
	public static final String VALIDATE_EMAIL = "validate_emali";
	
	/**
	 * 保存入住离店时间
	 * 
	 * @param context
	 * @param dates
	 */
	public static void setInOutHotelDates(Context context, ArrayList<Date> dates) {
		SerializableObject.saveObject(context, dates, IN_OUT_HOTEL_DATE);
	}

	/**
	 * 返回入住离店时间
	 * @param context
	 * @return
	 */
	public static ArrayList<Date> getInOutHotelDates(Context context) {
		ArrayList<Date> dates = (ArrayList<Date>) SerializableObject.readObject(context, IN_OUT_HOTEL_DATE);
		return dates;
	}
	
	/**
	 * 保存火车出发时间
	 * 
	 * @param context
	 * @param date
	 */
	public static void setTrainStartingDate(Context context, Date date) {
		SerializableObject.saveObject(context, date, TRAIN_STARTING_DATE);
	}

	/**
	 * 返回火车出发时间
	 * @param context
	 * @return
	 */
	public static Date getTrainStartingDate(Context context) {
		Date date = (Date) SerializableObject.readObject(context, TRAIN_STARTING_DATE);
		return date;
	}
	
	/**
	 * 价格星级
	 * @param priceLevelString
	 */
	public static void setPriceLevel(Context context, String priceLevelString) {
		ConfigManager.getInstance(context).putString(PRICE_LEVEL, priceLevelString);
	}
	
	/**
	 * 获取价格星级
	 * @param context
	 * @return
	 */
	public static String getPriceLevel(Context context) {
		return ConfigManager.getInstance(context).loadString(PRICE_LEVEL);
	}
	
	/**
	 * 当前选中城市
	 * @param context
	 * @param city
	 */
	public static void setHotelCity(Context context, City city){
		SerializableObject.saveObject(context, city, HOTEL_CITY);
	}
	
	/**
	 * 获取选中城市
	 * @param context
	 * @return
	 */
	public static City getHotelCity(Context context){
		City city = (City) SerializableObject.readObject(context, HOTEL_CITY);
		return city;
	}
	
	/**
	 * 当前选中起始火车站
	 * @param context
	 * @param city
	 */
	public static void setStartTrainStation(Context context, TrainStation trainStation){
		SerializableObject.saveObject(context, trainStation, START_TRAIN_STATION);
	}
	
	/**
	 * 获取选中起始火车站
	 * @param context
	 * @return
	 */
	public static TrainStation getStartTrainStation(Context context){
		TrainStation trainStation = (TrainStation) SerializableObject.readObject(context, START_TRAIN_STATION);
		return trainStation;
	}
	
	/**
	 * 当前选中起始火车站
	 * @param context
	 * @param city
	 */
	public static void setEndTrainStation(Context context, TrainStation trainStation){
		SerializableObject.saveObject(context, trainStation, END_TRAIN_STATION);
	}
	
	/**
	 * 获取选中起始火车站
	 * @param context
	 * @return
	 */
	public static TrainStation getEndTrainStation(Context context){
		TrainStation trainStation = (TrainStation) SerializableObject.readObject(context, END_TRAIN_STATION);
		return trainStation;
	}
	
	/**
	 * 当前选中城市
	 * @param context
	 * @param city
	 */
	public static void setHotelLocation(Context context, Poi poi){
		SerializableObject.saveObject(context, poi, HOTEL_LOCATION);
	}
	
	/**
	 * 获取选中城市
	 * @param context
	 * @return
	 */
	public static Poi getHotelLocation(Context context){
		Poi poi = (Poi) SerializableObject.readObject(context, HOTEL_LOCATION);
		return poi;
	}
	
	/**
	 * 保存用户姓名
	 * @param context
	 * @param liveName
	 */
	public static void setLiveName(Context context, String liveName){
		ConfigManager.getInstance(context).putString(LIVE_NAME, liveName);
	}
	
	/**
	 * 获取用户名
	 * @param context
	 * @return
	 */
	public static String getLiveName(Context context){
		return ConfigManager.getInstance(context).loadString(LIVE_NAME);
	}
	
	/**
	 * 保存电话
	 * @param context
	 * @param livePhone
	 */
	public static void setLivePhone(Context context, String livePhone) {
		ConfigManager.getInstance(context).putString(LIVE_PHONE, livePhone);
	}
	
	/**
	 * 获取电话号码
	 * @param context
	 * @return
	 */
	public static String getLivePhone(Context context){
		return ConfigManager.getInstance(context).loadString(LIVE_PHONE);
	}
	
//	/***/
//	public static final String INVOICE_TITLE = "invoice_title";
//	/**邮寄地址*/
//	public static final String MAIL_ADDRESS = "mail_address";
	
	/**
	 * 发票抬头
	 * @param context
	 * @param invoiceTitle
	 */
	public static void setInvoiceTitle(Context context, String invoiceTitle) {
		ConfigManager.getInstance(context).putString(INVOICE_TITLE, invoiceTitle);
	}
	
	/**
	 * 发票抬头
	 * @param context
	 * @return
	 */
	public static String getInvoiceTitle(Context context) {
		return ConfigManager.getInstance(context).loadString(INVOICE_TITLE);
	}
	
	/**
	 * 邮寄地址
	 * @param context
	 * @param invoiceTitle
	 */
	public static void setMailAddress(Context context, String invoiceTitle) {
		ConfigManager.getInstance(context).putString(MAIL_ADDRESS, invoiceTitle);
	}
	
	/**
	 * 邮寄地址
	 * @param context
	 * @return
	 */
	public static String getMailAddress(Context context) {
		return ConfigManager.getInstance(context).loadString(MAIL_ADDRESS);
	}
	
	/**
	 * 保存登陆电话号码
	 * @param context
	 * @param loginPhoneString
	 */
	public static void setLoginPhone(Context context, String loginPhoneString){
		ConfigManager.getInstance(context).putString(LOGIN_PHONE, loginPhoneString);
	}
	
	/**
	 * 获取登陆电话号码
	 * @param context
	 * @return
	 */
	public static String getLoginPhone(Context context) {
		return ConfigManager.getInstance(context).loadString(LOGIN_PHONE);
	}
	
	/**
	 * 保存联合登陆返回的昵称
	 * @param context
	 * @param nickName
	 */
	public static void setLoginNickName(Context context, String nickName){
		ConfigManager.getInstance(context).putString(LOGIN_NICKNAME, nickName);
	}
	
	/**
	 * 获取联合登陆返回的昵称
	 * @param context
	 * @return
	 */
	public static String getLoginNickName(Context context) {
		return ConfigManager.getInstance(context).loadString(LOGIN_NICKNAME);
	}
	
	/**
	 * 保存持卡人
	 * @param context
	 * @param cardholder
	 */
	public static void setCardholder(Context context, String cardholder){
		ConfigManager.getInstance(context).putString(CARDHOLDER, cardholder);
	}
	
	/**
	 * 获取持卡人
	 * @param context
	 * @param cardholder
	 */
	public static String getCardholder(Context context){
		return ConfigManager.getInstance(context).loadString(CARDHOLDER);
	}
	
	/**
	 * 保存身份证
	 * @param context
	 * @param idCardString
	 */
	public static void setIdCard(Context context, String idCardString){
		ConfigManager.getInstance(context).putString(ID_CARD, idCardString);
	}
	
	/**
	 * 获取身份证
	 * @param context
	 */
	public static String getIdCard(Context context) {
		return ConfigManager.getInstance(context).loadString(ID_CARD);
	}
	
	/**
	 * 保存信用卡卡号
	 * @param context
	 * @param creditCardNumber
	 */
	public static void setCreditCardNumber(Context context, String creditCardNumber){
		ConfigManager.getInstance(context).putString(CREDIT_CARD_NUMBER, creditCardNumber);
	}
	
	/**
	 * 获取信用卡卡号
	 * @param context
	 * @return
	 */
	public static String getCreditCardNumber(Context context){
		return ConfigManager.getInstance(context).loadString(CREDIT_CARD_NUMBER);
	}
	
	/**
	 * 设置cvv2
	 * @param context
	 * @param cvv2String
	 */
	public static void setCvv2(Context context, String cvv2String){
		ConfigManager.getInstance(context).putString(CVV2, cvv2String);
	}
	
	/**
	 * 获取cvv2
	 * @param context
	 * @return
	 */
	public static String getCvv2(Context context){
		return ConfigManager.getInstance(context).loadString(CVV2);
	}
	
	/**
	 * 收件人
	 * @param context
	 * @param recipients
	 */
	public static void setRecipients(Context context, String recipients){
		ConfigManager.getInstance(context).putString(RECIPIENTS, recipients);
	}
	
	/**
	 * 获取收件人
	 * @param context
	 * @return
	 */
	public static String getRecipients(Context context){
		return ConfigManager.getInstance(context).loadString(RECIPIENTS);
	}
	
	/**
	 * 收件人电话号
	 * @param context
	 * @param recipients
	 */
	public static void setRecipientsPhone(Context context, String recipientsPhone){
		ConfigManager.getInstance(context).putString(RECIPIENTS_PHONE, recipientsPhone);
	}
	
	/**
	 * 获取收件人电话号
	 * @param context
	 * @return
	 */
	public static String getRecipientsPhone(Context context){
		return ConfigManager.getInstance(context).loadString(RECIPIENTS_PHONE);
	}
	
	/**
	 * 保存上一次的版本，用来比较是否弹出引导页
	 * @param context
	 * @param currentVersion
	 */
	public static void setLastVersionCode(Context context, String lastVersionCode) {
		ConfigManager.getInstance(context).putString(LAST_VERSION_CODE, lastVersionCode);
	}
	
	/**
	 * 获取上一次的版本，用来比较是否弹出引导页
	 * @param context
	 * @return
	 */
	public static String getLastVersionCode(Context context) {
		return ConfigManager.getInstance(context).loadString(LAST_VERSION_CODE);
	}
	
	/**
	 * 保存验证邮箱
	 * @param context
	 * @param currentVersion
	 */
	public static void setValidateEmali(Context context, String validateEmali) {
		ConfigManager.getInstance(context).putString(VALIDATE_EMAIL, validateEmali);
	}
	
	/**
	 * 获取获取验证邮箱
	 * @param context
	 * @return
	 */
	public static String getValidateEmali(Context context) {
		return ConfigManager.getInstance(context).loadString(VALIDATE_EMAIL);
	}
}
